﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _1多态
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private List<Animal> arrayList;
        private void Button1_Click(object sender, EventArgs e)
        {
            arrayList=new List<Animal>();
            arrayList.Add(new Cat("小花"));
            arrayList.Add(new Dog("阿毛"));
            arrayList.Add(new Dog("小黑"));
            arrayList.Add(new Cat("咪咪"));
            arrayList.Add(new Cat("小猫"));
            arrayList.Add(new Sheep("绵绵"));
            arrayList.Add(new Cattle("牛牛"));
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            foreach (Animal animal in arrayList)
            {
                MessageBox.Show(animal.Shout());
            }
        }
    }
}
